//
//  SNCompilePlanOtherButton.m
//  ZhuoxinAgriculture
//
//  Created by stone on 16/12/28.
//  Copyright © 2016年 stone. All rights reserved.
//

#import "SNCompilePlanOtherButton.h"

@implementation SNCompilePlanOtherButton
-(void)setHighlighted:(BOOL)highlighted{
    
}
- (CGSize)intrinsicContentSize {
    CGSize intrinsicSuperViewContentSize = [super intrinsicContentSize] ;
    intrinsicSuperViewContentSize.width += (_PADDINGLEFTANDRIGHT + _PADDINGLEFTANDRIGHT + _imageToLabelInterval) ;
    intrinsicSuperViewContentSize.height += (_PADDINGTOPANDBOTTOM + _PADDINGTOPANDBOTTOM);
    return intrinsicSuperViewContentSize ;
}
-(void)setPADDINGTOPANDBOTTOM:(CGFloat)PADDINGTOPANDBOTTOM{
    PADDINGTOPANDBOTTOM = PADDINGTOPANDBOTTOM * 0.5;
    _PADDINGTOPANDBOTTOM = PADDINGTOPANDBOTTOM;
    
    [self setContentEdgeInsets:UIEdgeInsetsMake(PADDINGTOPANDBOTTOM, _PADDINGLEFTANDRIGHT, PADDINGTOPANDBOTTOM, _PADDINGLEFTANDRIGHT)];
    [self invalidateIntrinsicContentSize];
    
}
-(void)setPADDINGLEFTANDRIGHT:(CGFloat)PADDINGLEFTANDRIGHT{
    PADDINGLEFTANDRIGHT = PADDINGLEFTANDRIGHT * 0.5;
    _PADDINGLEFTANDRIGHT = PADDINGLEFTANDRIGHT;
    
    
    [self setContentEdgeInsets:UIEdgeInsetsMake(_PADDINGTOPANDBOTTOM, PADDINGLEFTANDRIGHT, _PADDINGTOPANDBOTTOM, PADDINGLEFTANDRIGHT)];
    [self invalidateIntrinsicContentSize];
    
}
-(void)setImageToLabelInterval:(CGFloat)imageToLabelInterval{
    _imageToLabelInterval = imageToLabelInterval;
    
    //    [self setNeedsDisplay];
    //    CGFloat padding = 10.0f;
    //    [self setTitleEdgeInsets:UIEdgeInsetsMake(0, _PADDING, 0, -PADDING)];
    // 6
    [self setImageEdgeInsets:UIEdgeInsetsMake(0, -imageToLabelInterval*0.5, 0, imageToLabelInterval * 0.5)];
    [self setTitleEdgeInsets:UIEdgeInsetsMake(0, imageToLabelInterval*0.5, 0, -imageToLabelInterval*0.5)];
    [self invalidateIntrinsicContentSize];
}
/**
 *  设置边框宽度
 *
 *  @param borderWidth 可视化视图传入的值
 */
- (void)setBorderWidth:(CGFloat)borderWidth {
    
    if (borderWidth < 0) return;
    
    self.layer.borderWidth = borderWidth;
}

/**
 *  设置边框颜色
 *
 *  @param borderColor 可视化视图传入的值
 */
- (void)setBorderColor:(UIColor *)borderColor {
    
    self.layer.borderColor = borderColor.CGColor;
}

/**
 *  设置圆角
 *
 *  @param cornerRadius 可视化视图传入的值
 */
- (void)setCornerRadius:(CGFloat)cornerRadius {
    
    self.layer.cornerRadius = cornerRadius;
    self.layer.masksToBounds = cornerRadius > 0;
}

@end
